import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

// Bus公共组件
import '@/utils/eventBus'

// Utils下公共方法,请求方式和cdn图片
import utils from '@/utils'
import Common from './utils/common'

// 返回顶部
import BackToTop from '@/components/BackToTop'

// Api
import api from './api/api'

// Vant
import Vant from 'vant'
import 'vant/lib/index.css'

// Swiper轮播9999
import 'swiper/css/swiper.css'
import VueAwesomeSwiper from 'vue-awesome-swiper'

Vue.use(utils)
Vue.use(Common)

Vue.component('BackToTop', BackToTop)

Vue.use(api)

Vue.use(Vant)

Vue.use(VueAwesomeSwiper /* { default options with global component } */)

Vue.config.productionTip = false

router.beforeEach((to, from, next) => {
  /* 路由发生变化修改页面title */
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})

router.afterEach(route => {
  window.scrollTo(0, 0)
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
